package org.huangjie.ddns;

import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;

public class Dynv6DDns implements DDns<String>{

    private String password = "fWynnSfbAiYMKNP7zL6evULxQF6SLc";
    private String host = "myfamily.dns.army";
    private String ydnsUrl = "http://dynv6.com/api/update/";

    @Override
    public String update(String ip) {
        String url = StrUtil.format("{}?hostname={}&token={}&ipv6={}",ydnsUrl, host, password,ip);
        String body = HttpRequest.get(url)
                .execute().body();
        if (body.contains("updated")) {
            System.out.println("更新成功:"+body);
        }
        return body;
    }

    @Override
    public String getDomain() {
        return host;
    }
}
